package com.example.physicalexaminationsystem.dto;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.example.physicalexaminationsystem.enums.ResultCodeEnum;
import lombok.Data;

/**
 * @author shiwenzhuo
 * 
 * @description
 */
@Data
public class ResponseDto {
    private Integer code;
    private String message;
    private Object data;

    public static ResponseDto success(Object data) {
        ResponseDto responseDto = new ResponseDto();
        responseDto.setCode(ResultCodeEnum.SUCCESS.getStatus());
        responseDto.setMessage(ResultCodeEnum.SUCCESS.getDesc());
        responseDto.setData(data);
        return responseDto;
    }

    public static ResponseDto success() {
        ResponseDto responseDto = new ResponseDto();
        responseDto.setCode(ResultCodeEnum.SUCCESS.getStatus());
        responseDto.setMessage(ResultCodeEnum.SUCCESS.getDesc());
        return responseDto;
    }

    public static ResponseDto fail(String message) {
        ResponseDto responseDto = new ResponseDto();
        responseDto.setCode(ResultCodeEnum.ERROR.getStatus());
        responseDto.setMessage(message);
        return responseDto;
    }
}
